import React from 'react'
import './index.css'
import PropTypes from 'prop-types'
import types from '../../utils/commonTypes'

export default function Modal(props) {
    return (
        <div className="modal" style={{
            backgroundColor: props.bg
        }} onClick={() => { props.onClose() }}>
            <div className="modal-center" onClick={(e) => e.stopPropagation()}>
                {props.children}
            </div>
        </div>
    )
}

Modal.defaultProps = {
    bg: "rgba(0,0,0,0.4)",
    onClose: () => { },
}

Modal.propTypes = {
    bg: PropTypes.string,
    onClose: PropTypes.func,
    children: types.children
}